package com.ecfront.test.dao;

import java.util.Iterator;
import java.util.List;

import com.ecfront.dao.UserGradeDAO;
import com.ecfront.pojo.User;
import com.ecfront.pojo.UserGrade;
import junit.framework.TestCase;

public class testUserGrade extends TestCase {
	private static final UserGradeDAO userGradeDao = (UserGradeDAO)SpringUtilTest.getBean("UserGradeDAO");
	//保存测试
	public void testSave(){
		UserGrade ug = new UserGrade();
		ug.setId(1);
		ug.setImgUrl("\\img\\1.jpg");
		ug.setName("黄金勋章");
		ug.setScore(1000);
		userGradeDao.save(ug);
	}
	//素有属性测试
	public void testFindAll(){
		List list = userGradeDao.findAll();
		for(Iterator iter = list.iterator();iter.hasNext();){
			UserGrade ug = (UserGrade)iter.next();
			System.out.println(ug.getName());
			System.out.println(ug.getImgUrl());
			System.out.println(ug.getScore());
			for(Iterator iter1 = ug.getUsers().iterator();iter1.hasNext();){
				User user = (User)iter1.next();
				System.out.println(user.getName());
			}
		}
	}
	//删除测试
	public void testDel(){
		UserGrade ug = new UserGrade();
		ug.setId(1);
		userGradeDao.delete(ug);
	}
	//属性测试
	public void testProperties(){
//		UserGrade ug = userGradeDao.findById(2);
//		System.out.println(ug.getName());
		List list = userGradeDao.findByUgScore(1000);
		for(Iterator iter = list.iterator();iter.hasNext();){
			UserGrade ug = (UserGrade)iter.next();
			System.out.println(ug.getName());
			System.out.println(ug.getImgUrl());
			System.out.println(ug.getScore());
		}
	}
}
